<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>继承</title>
</head>
<body>
</body>
<script>
    //创建动物类
    class Animal {
        //constructor 构造方法
        constructor(name, age) {
            this.name = name;
            this.age = age;
        }

        //sleep方法
        sleep() {
            document.write("睡觉");
        }
    }

    //继承
    class dog extends Animal {
        constructor(name, age, color) {
            super(name, age);
            this.color = color;
        }

        show() {
            document.write(this.name + "," + this.age + "," + this.color + "," + "<br>");
        }
    }

    //创建对象,使用dog类
    let d = new dog("狗", 3, "黄色");
    d.show();
    d.sleep();
</script>
</html>